package com.todo.event.activity.application.backend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.event.activity.application.backend.service.EventDecisionBackendService;
import com.todo.event.activity.iface.backend.EventDecisionBackendIface;
import com.todo.event.activity.iface.backend.request.*;
import com.todo.event.activity.iface.backend.response.EventDecisionBaseResp;
import com.todo.event.activity.iface.backend.response.EventDecisionDetailResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2025/1/11 20:57
 * @description
 */
@RestController
@RequestMapping("/bd/event/decision")
@Tag(name = "事件决策配置后台处理类", description = "事件决策配置后台处理类")
public class EventDecisionBackendController implements EventDecisionBackendIface {

    @Resource
    private EventDecisionBackendService eventDecisionBackendService;

    @Override
    @Operation(summary = "新增事件决策")
    @PostMapping("/insertEventDecision")
    public BizResponse<Boolean> insertEventDecision(@RequestBody InsertEventDecisionReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventDecisionBackendService.insertEventDecision(req);
    }

    @Override
    @Operation(summary = "更新事件决策")
    @PostMapping("/updateEventDecision")
    public BizResponse<Boolean> updateEventDecision(@RequestBody UpdateEventDecisionReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventDecisionBackendService.updateEventDecision(req);
    }

    @Override
    @Operation(summary = "根据主键删除事件决策")
    @PostMapping("/removeEventDecisionById")
    public BizResponse<Boolean> removeEventDecisionById(@RequestBody RemoveEventDecisionByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventDecisionBackendService.removeEventDecisionById(req);
    }

    @Override
    @Operation(summary = "根据主键查询事件决策详情")
    @PostMapping("/queryEventDecisionById")
    public BizResponse<EventDecisionDetailResp> queryEventDecisionById(@RequestBody QueryEventDecisionDetailByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventDecisionBackendService.queryEventDecisionById(req);
    }

    @Override
    @Operation(summary = "分页查询事件决策基础信息")
    @PostMapping("/queryEventDecisionPage")
    public BizPageResponse<EventDecisionBaseResp> queryEventDecisionPage(@RequestBody QueryEventDecisionPageReq req) {
        if (req == null) {
            return BizPageResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizPageResponse.paramError("参数错误");
        }
        return eventDecisionBackendService.queryEventDecisionPage(req);
    }

    @Override
    @Operation(summary = "事件决策配置测试 - 目前暂无具体测试逻辑，默认测试通过，后续可扩展")
    @PostMapping("/testEventDecisionProperty")
    public BizResponse<String> testEventDecisionProperty(@RequestBody TestEventDecisionPropertyReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventDecisionBackendService.testEventDecisionProperty(req);
    }

    @Override
    @Operation(summary = "启用事件决策")
    @PostMapping("/enableEventDecision")
    public BizResponse<Boolean> enableEventDecision(@RequestBody EnableEventDecisionReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventDecisionBackendService.enableEventDecision(req);
    }
}
